# -*- coding: utf-8 -*-
# @Time    : 2022/8/6 19:19
# @Author  : Weijian Yi
# @File    : serializers.py
# @Software: PyCharm
from rest_framework import serializers
from .models import *


class UserSerializer(serializers.ModelSerializer):
    class Meta:
        model = MyUser
        fields = ("id",
                  "username",
                  "is_superuser",
                  "gender",
                  "nationality",
                  "age",
                  "join_group_age",
                  "belong_to_group")


class GroupSerializer(serializers.ModelSerializer):
    create_time = serializers.DateTimeField(format='%Y-%m-%d %H:%M:%S')

    class Meta:
        model = MyGroup
        fields = "__all__"


class NewsListSerializer(serializers.ModelSerializer):
    create_time = serializers.DateTimeField(format='%Y-%m-%d %H:%M:%S')

    class Meta:
        model = News
        fields = ("id", "title", 'author', 'create_time')


class NewDetailSerializer(serializers.ModelSerializer):
    create_time = serializers.DateTimeField(format='%Y-%m-%d %H:%M:%S')

    class Meta:
        model = News
        fields = "__all__"
